package com.ctrlcar.giftrecord.config;


import com.ctrlcar.giftrecord.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author:
 * @Description: 配置拦截器
 * @DateTime: 2024/10/9 17:56
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {
    //拦截对象
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
        //拦截路径
        registry.addInterceptor(loginInterceptor)
//                .addPathPatterns("/**")//设置拦截器拦截的请求路径（ /** 表示拦截所有请求）
                .excludePathPatterns("/**");//设置不拦截全部（测试用）
//                .excludePathPatterns( "/user/**"); // 排除 /user
    }
}
